<template>
<!--  <el-dialog-->
<!--    title="详情"-->
<!--    :close-on-click-modal="false"-->
<!--    :visible.sync="visible">-->
  <div class="fillcontain" >

    <div class="head-title"> <i class="el-icon-edit-outline">模型详情</i></div>
    <el-form :model="dataForm"  ref="dataForm"  label-width="80px" class="form-container">

      <el-row>
        <el-col :span="12">
          <el-form-item label="模型标识" prop="entityIdentify">
            <el-input v-model="dataForm.entityIdentify" disabled placeholder="模型标识"></el-input>
<!--            <el-select v-model="dataForm.entityIdentify" disabled filterable placeholder="请选择">-->
<!--              <el-option-->
<!--                v-for="item in entitys"-->
<!--                :key="item.name"-->
<!--                :label="item.name"-->
<!--                :value="item.name"-->
<!--                @click.native="changeEntity(item)">-->
<!--              </el-option>-->
<!--            </el-select>-->
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="模型名称" prop="entityName">
            <el-input v-model="dataForm.entityName" disabled placeholder="模型名称"></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="包路径" prop="pkgName">
            <el-input v-model="dataForm.pkgName" disabled placeholder="包路径"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="是否有效" disabled prop="isEffect">
            <el-switch
              disabled
              v-model="dataForm.isEffect"
              active-color="#13ce66"
              inactive-color="#ff4949"
              on-value="1" on-text="是" off-text="否" off-value="0">
            </el-switch>
          </el-form-item>
        </el-col>
      </el-row>
      <el-form-item  label="备注" prop="remark">
        <el-input  type="textarea" disabled :rows="2" v-model="dataForm.remark" placeholder="备注"></el-input>
      </el-form-item>
    </el-form>

    <div class="mb10 pl20">
      <div class="content-title"><span>属性</span></div>
      <el-table
        :data="dataList"
        style="width: 100%;margin-bottom: 20px;"
        row-key="filedName"
        border
        default-expand-all
        :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
        <el-table-column
          prop="chName"
          label="因子名称"
          sortable
          width="180">
        </el-table-column>
        <el-table-column
          prop="filedName"
          label="因子标识"
          sortable
          width="180">
        </el-table-column>
        <el-table-column
          prop="filedType"
          label="因子类型">
        </el-table-column>
      </el-table>
    </div>

    <div class="content-footer">
      <el-button @click="toList">返回</el-button>
    </div>
  </div>
<!--  </el-dialog>-->
</template>

<script>
  import {getInfo, entityList } from '@/api/baseConfig/entity'
  import constant from "../../../../../api/constant";

  export default {
    data () {
      return {
        dataList: [],
          entitys: [],
        visible: false,
        dataForm: {
          id: null,
          entityId: null,
          entityName: '',
          entityDesc: '',
          entityIdentify: '',
          pkgName: '',
          remark: '',
          isEffect: '1'
        }
      }
    },
    created () {
        let id = this.$route.params.id
        this.init(id)
        this.getEntityCls()
    },
    methods: {
        toList(){
            constant.clearTag(this)
            this.$router.push({name: constant.routerName.listEntity})
        },
        // 获取实体类列表
        getEntityCls() {
            entityList({}).then(res => {
                if (res.data.data) {
                    this.entitys = res.data.data
                }
            })
        },
      init (id) {
        this.dataForm.id = id
        this.visible = true
        this.dataList = []

        this.$nextTick(() => {
          // this.$refs['dataForm'].resetFields()
          if (this.dataForm.id) {
            let params = {
              id: this.dataForm.id + ''
            }
              this.$store.dispatch('loading/CHANGE_LOADING', true)
            getInfo(params).then(res => {
                this.$store.dispatch('loading/CHANGE_LOADING', false)
              if (res.data.data && res.data.resultCode === 0) {
                this.dataForm = res.data.data.entity
                this.dataList = res.data.data.proList
              }
            }).catch(err=>{
                this.$store.dispatch('loading/CHANGE_LOADING', false)
            })
          }
        })
      },


    }
  }
</script>

<style lang="scss">
  .title{
    padding: 10px;
    background-color: rgba(248, 248, 248, 1);
    margin-bottom: 10px;
  }
  .el-table__row .el-form-item__content{
    margin-left: 0 !important;
  }
  .el-table__row .el-form-item{
    margin-bottom: 0 !important;
  }
</style>
